package com.tuo51.evaluate.domain.export;

import com.tuo51.foudation.model.UnionTypeID;
import lombok.Data;

import javax.persistence.*;
import java.util.Date;

/**
 * 月龄对应的操作，对应测评表的月单元格
 */

@Data
@Entity
@Table(name = "tb_evaluate_export_record")
public class EvaluateExportRecord {

    @Column(columnDefinition = " datetime DEFAULT NOW() COMMENT '创建时间' ")
    private Date created = new Date();

    @Column(columnDefinition = "varchar(255) COMMENT '静态化文件 URL' ")
    private String staticURL;

    @EmbeddedId
    @AttributeOverrides({
            @AttributeOverride(name = "domainId", column = @Column(name ="objectID", nullable = false, length =32, columnDefinition = "varchar(50) COMMENT '导出对象的 id' ")),
            @AttributeOverride(name = "type",column = @Column(name="type", nullable = false,length = 32,columnDefinition = "int default 0 COMMENT '导出类型， 0：能力发展测评， 1：心里行为测评， 2：二宝测评'"))})
    private UnionTypeID typeID;

//    @Column(columnDefinition = "varchar(50) COMMENT '导出对象的 id' ")
//    private String objectID;
//
//    @Column(columnDefinition = "int default 0 COMMENT '导出类型， 0：能力发展测评， 1：心里行为测评， 2：二宝测评'")
//    private Integer type = 0;

    public static EvaluateExportRecord of(Integer type, String objectID, String staticURL){
        EvaluateExportRecord ret = new EvaluateExportRecord();

        ret.setStaticURL(staticURL);
        ret.setTypeID(UnionTypeID.of(objectID, type));

        return ret;
    }
}
